﻿<?xml version="1.0" encoding="utf-8" ?>
<rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       replacementText="¤"
       unmatchedAction="EmitReplacement"
       author="Kirk"
       title="Black Speech"
       copyright="Open source distributed without warranty of any kind"
       caseSensitive="false"
       xmlns="http://transcriber.codeplex.com/Rules.xsd">
  
  <!-- PUT INPUT INTO CANONICAL FORM -->
  
  <!-- remove mystery diacriticals -->
  <rule pattern="[äà]">
    <intermediate>a</intermediate>
  </rule>

  <!-- remove mystery diacriticals -->
  <rule pattern="[ëè]">
    <intermediate>e</intermediate>
  </rule>

  <!-- remove mystery diacriticals -->
  <rule pattern="[ïì]">
    <intermediate>i</intermediate>
  </rule>

  <!-- remove mystery diacriticals -->
  <rule pattern="[öò]">
    <intermediate>o</intermediate>
  </rule>

  <!-- remove mystery diacriticals -->
  <rule pattern="[üù]">
    <intermediate>u</intermediate>
  </rule>

  <!-- set up for initial f rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})f">
    <intermediate>${prefix}ÿ</intermediate>
  </rule>

  <!-- set up for initial th rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})th">
    <intermediate>${prefix}@</intermediate>
  </rule>

  <!-- set up for initial sh rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})sh">
    <intermediate>${prefix}ý</intermediate>
  </rule>

  <!-- set up for initial kh rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})kh">
    <intermediate>${prefix}§</intermediate>
  </rule>

  <!-- set up for initial dh rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})dh">
    <intermediate>${prefix}¶</intermediate>
  </rule>

  <!-- set up for initial v rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})v">
    <intermediate>${prefix}º</intermediate>
  </rule>

  <!-- set up for initial zh rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})zh">
    <intermediate>${prefix}®</intermediate>
  </rule>

  <!-- set up for initial gh rule -->
  <rule pattern="(?&lt;prefix&gt;(^|\s+)[aeiou]{0,1})gh">
    <intermediate>${prefix}∞</intermediate>
  </rule>
  
  <!-- set up for final r rule -->
  <rule pattern="r($|\s+)">
    <intermediate>¥$1</intermediate>
  </rule>

  <!-- set up for ch rule -->
  <rule pattern="ch">
    <intermediate>©</intermediate>
  </rule>

  <!-- replace c with k -->
  <rule pattern="c">
    <intermediate>k</intermediate>
  </rule>

  <!-- NUMBERS -->

  <import filename="TengwarNumerals.xml"/>
  
  <!-- COMPOUND CONSONANTS -->

  <!-- th -->
  <rule pattern="a@">
    <final>!D</final>
  </rule>

  <rule pattern="e@">
    <final>!F</final>
  </rule>

  <rule pattern="i@">
    <final>!G</final>
  </rule>

  <rule pattern="o@">
    <final>!J</final>
  </rule>

  <rule pattern="u@">
    <final>!H</final>
  </rule>

  <rule pattern="@">
    <final>!</final>
  </rule>

  <rule pattern="ath">
    <final>3D</final>
  </rule>

  <rule pattern="eth">
    <final>3F</final>
  </rule>

  <rule pattern="ith">
    <final>3G</final>
  </rule>

  <rule pattern="oth">
    <final>3J</final>
  </rule>

  <rule pattern="uth">
    <final>3H</final>
  </rule>

  <rule pattern="th">
    <final>3</final>
  </rule>

  <!-- sh -->
  <rule pattern="aý">
    <final>A#</final>
  </rule>

  <rule pattern="eý">
    <final>A$</final>
  </rule>

  <rule pattern="iý">
    <final>A%</final>
  </rule>

  <rule pattern="oý">
    <final>A&amp;</final>
  </rule>

  <rule pattern="uý">
    <final>A^</final>
  </rule>

  <rule pattern="ý">
    <final>A</final>
  </rule>

  <rule pattern="ash">
    <final>d#</final>
  </rule>

  <rule pattern="esh">
    <final>d$</final>
  </rule>

  <rule pattern="ish">
    <final>d%</final>
  </rule>

  <rule pattern="osh">
    <final>d&amp;</final>
  </rule>

  <rule pattern="ush">
    <final>d^</final>
  </rule>

  <rule pattern="sh">
    <final>d</final>
  </rule>

  <!-- kh -->
  <rule pattern="a§">
    <final>Z#</final>
  </rule>

  <rule pattern="e§">
    <final>Z$</final>
  </rule>

  <rule pattern="i§">
    <final>Z%</final>
  </rule>

  <rule pattern="o§">
    <final>Z&amp;</final>
  </rule>

  <rule pattern="u§">
    <final>Z^</final>
  </rule>

  <rule pattern="§">
    <final>Z</final>
  </rule>

  <rule pattern="akh">
    <final>c#</final>
  </rule>

  <rule pattern="ekh">
    <final>c$</final>
  </rule>

  <rule pattern="ikh">
    <final>c%</final>
  </rule>

  <rule pattern="okh">
    <final>c&amp;</final>
  </rule>

  <rule pattern="ukh">
    <final>c^</final>
  </rule>

  <rule pattern="kh">
    <final>c</final>
  </rule>

  <!-- dh -->
  <rule pattern="a¶">
    <final>@#</final>
  </rule>

  <rule pattern="e¶">
    <final>@$</final>
  </rule>

  <rule pattern="i¶">
    <final>@%</final>
  </rule>

  <rule pattern="o¶">
    <final>@&amp;</final>
  </rule>

  <rule pattern="u¶">
    <final>@^</final>
  </rule>

  <rule pattern="¶">
    <final>@</final>
  </rule>

  <rule pattern="adh">
    <final>4#</final>
  </rule>

  <rule pattern="edh">
    <final>4$</final>
  </rule>

  <rule pattern="idh">
    <final>4%</final>
  </rule>

  <rule pattern="odh">
    <final>4&amp;</final>
  </rule>

  <rule pattern="udh">
    <final>4^</final>
  </rule>

  <rule pattern="dh">
    <final>4</final>
  </rule>

  <!-- zh -->
  <rule pattern="a®">
    <final>S#</final>
  </rule>

  <rule pattern="e®">
    <final>S$</final>
  </rule>

  <rule pattern="i®">
    <final>S%</final>
  </rule>

  <rule pattern="o®">
    <final>S&amp;</final>
  </rule>

  <rule pattern="u®">
    <final>S^</final>
  </rule>

  <rule pattern="®">
    <final>S</final>
  </rule>

  <rule pattern="azh">
    <final>f#</final>
  </rule>

  <rule pattern="ezh">
    <final>f$</final>
  </rule>

  <rule pattern="izh">
    <final>f%</final>
  </rule>

  <rule pattern="ozh">
    <final>f&amp;</final>
  </rule>

  <rule pattern="uzh">
    <final>f^</final>
  </rule>

  <rule pattern="zh">
    <final>f</final>
  </rule>

  <!-- gh -->
  <rule pattern="a∞">
    <final>X#</final>
  </rule>

  <rule pattern="e∞">
    <final>X$</final>
  </rule>

  <rule pattern="i∞">
    <final>X%</final>
  </rule>

  <rule pattern="o∞">
    <final>X&amp;</final>
  </rule>

  <rule pattern="u∞">
    <final>X^</final>
  </rule>

  <rule pattern="∞">
    <final>X</final>
  </rule>

  <rule pattern="agh">
    <final>v#</final>
  </rule>

  <rule pattern="egh">
    <final>v$</final>
  </rule>

  <rule pattern="igh">
    <final>v%</final>
  </rule>

  <rule pattern="ogh">
    <final>v&amp;</final>
  </rule>

  <rule pattern="ugh">
    <final>v^</final>
  </rule>

  <rule pattern="gh">
    <final>v</final>
  </rule>

  <!-- ny -->
  <rule pattern="any">
    <final>g#</final>
  </rule>

  <rule pattern="eny">
    <final>g$</final>
  </rule>

  <rule pattern="iny">
    <final>g%</final>
  </rule>

  <rule pattern="ony">
    <final>g&amp;</final>
  </rule>

  <rule pattern="uny">
    <final>g^</final>
  </rule>

  <rule pattern="ny">
    <final>g</final>
  </rule>

  <!-- ng -->
  <rule pattern="ang">
    <final>b#</final>
  </rule>

  <rule pattern="eng">
    <final>b$</final>
  </rule>

  <rule pattern="ing">
    <final>b%</final>
  </rule>

  <rule pattern="ong">
    <final>b&amp;</final>
  </rule>

  <rule pattern="ung">
    <final>b^</final>
  </rule>

  <rule pattern="ng">
    <final>b</final>
  </rule>
  
  <!-- rh -->
  <rule pattern="arh">
    <final>uE</final>
  </rule>

  <rule pattern="erh">
    <final>uF</final>
  </rule>

  <rule pattern="irh">
    <final>uG</final>
  </rule>

  <rule pattern="orh">
    <final>uJ</final>
  </rule>

  <rule pattern="urh">
    <final>uH</final>
  </rule>

  <rule pattern="rh">
    <final>u</final>
  </rule>

  <!-- lh -->
  <rule pattern="alh">
    <final>m#</final>
  </rule>

  <rule pattern="elh">
    <final>m$</final>
  </rule>

  <rule pattern="ilh">
    <final>m%</final>
  </rule>

  <rule pattern="olh">
    <final>m&amp;</final>
  </rule>

  <rule pattern="ulh">
    <final>m^</final>
  </rule>

  <rule pattern="lh">
    <final>m</final>
  </rule>
  
  <!-- hw -->
  <rule pattern="ahw|awh">
    <final>o#</final>
  </rule>

  <rule pattern="ehw|ewh">
    <final>o$</final>
  </rule>

  <rule pattern="ihw|iwh">
    <final>o%</final>
  </rule>

  <rule pattern="ohw|owh">
    <final>o&amp;</final>
  </rule>

  <rule pattern="uhw|uwh">
    <final>o^</final>
  </rule>

  <rule pattern="hw|wh">
    <final>o</final>
  </rule>

  <!-- SHORT (SINGLE) CONSONANTS -->

  <!-- t -->
  <rule pattern="at">
    <final>1E</final>
  </rule>

  <rule pattern="et">
    <final>1R</final>
  </rule>

  <rule pattern="it">
    <final>1T</final>
  </rule>

  <rule pattern="ot">
    <final>1U</final>
  </rule>

  <rule pattern="ut">
    <final>1Y</final>
  </rule>

  <rule pattern="t">
    <final>1</final>
  </rule>

  <!-- p -->
  <rule pattern="ap">
    <final>qE</final>
  </rule>

  <rule pattern="ep">
    <final>qR</final>
  </rule>

  <rule pattern="ip">
    <final>qT</final>
  </rule>

  <rule pattern="op">
    <final>qU</final>
  </rule>

  <rule pattern="up">
    <final>qY</final>
  </rule>

  <rule pattern="p">
    <final>q</final>
  </rule>

  <!-- ch -->
  <rule pattern="a©">
    <final>aE</final>
  </rule>

  <rule pattern="e©">
    <final>aR</final>
  </rule>

  <rule pattern="i©">
    <final>aT</final>
  </rule>

  <rule pattern="o©">
    <final>aU</final>
  </rule>

  <rule pattern="u©">
    <final>aY</final>
  </rule>

  <rule pattern="©">
    <final>a</final>
  </rule>

  <!-- k -->
  <rule pattern="ak">
    <final>zE</final>
  </rule>

  <rule pattern="ek">
    <final>zR</final>
  </rule>

  <rule pattern="ik">
    <final>zT</final>
  </rule>

  <rule pattern="ok">
    <final>zU</final>
  </rule>

  <rule pattern="uk">
    <final>zY</final>
  </rule>

  <rule pattern="k">
    <final>z</final>
  </rule>

  <!-- d -->
  <rule pattern="ad">
    <final>2E</final>
  </rule>

  <rule pattern="ed">
    <final>2R</final>
  </rule>

  <rule pattern="id">
    <final>2T</final>
  </rule>

  <rule pattern="od">
    <final>2U</final>
  </rule>

  <rule pattern="ud">
    <final>2Y</final>
  </rule>

  <rule pattern="d">
    <final>2</final>
  </rule>

  <!-- b -->
  <rule pattern="ab">
    <final>wE</final>
  </rule>

  <rule pattern="eb">
    <final>wR</final>
  </rule>

  <rule pattern="ib">
    <final>wT</final>
  </rule>

  <rule pattern="ob">
    <final>wU</final>
  </rule>

  <rule pattern="ub">
    <final>wY</final>
  </rule>

  <rule pattern="b">
    <final>w</final>
  </rule>

  <!-- j -->
  <rule pattern="aj">
    <final>sE</final>
  </rule>

  <rule pattern="ej">
    <final>sR</final>
  </rule>

  <rule pattern="ij">
    <final>sT</final>
  </rule>

  <rule pattern="oj">
    <final>sU</final>
  </rule>

  <rule pattern="uj">
    <final>sY</final>
  </rule>

  <rule pattern="j">
    <final>s</final>
  </rule>

  <!-- g -->
  <rule pattern="ag">
    <final>xE</final>
  </rule>

  <rule pattern="eg">
    <final>xR</final>
  </rule>

  <rule pattern="ig">
    <final>xT</final>
  </rule>

  <rule pattern="og">
    <final>xU</final>
  </rule>

  <rule pattern="ug">
    <final>xY</final>
  </rule>

  <rule pattern="g">
    <final>x</final>
  </rule>

  <!-- f -->
  <rule pattern="aÿ">
    <final>QD</final>
  </rule>

  <rule pattern="eÿ">
    <final>QF</final>
  </rule>

  <rule pattern="iÿ">
    <final>QG</final>
  </rule>

  <rule pattern="oÿ">
    <final>QJ</final>
  </rule>

  <rule pattern="uÿ">
    <final>QH</final>
  </rule>

  <rule pattern="ÿ">
    <final>Q</final>
  </rule>

  <rule pattern="af">
    <final>eD</final>
  </rule>

  <rule pattern="ef">
    <final>eF</final>
  </rule>

  <rule pattern="if">
    <final>eG</final>
  </rule>

  <rule pattern="of">
    <final>eJ</final>
  </rule>

  <rule pattern="uf">
    <final>eH</final>
  </rule>

  <rule pattern="f">
    <final>e</final>
  </rule>

  <!-- v -->
  <rule pattern="aº">
    <final>W#</final>
  </rule>

  <rule pattern="eº">
    <final>W$</final>
  </rule>

  <rule pattern="iº">
    <final>W%</final>
  </rule>

  <rule pattern="oº">
    <final>W&amp;</final>
  </rule>

  <rule pattern="uº">
    <final>W^</final>
  </rule>

  <rule pattern="º">
    <final>W</final>
  </rule>

  <rule pattern="av">
    <final>r#</final>
  </rule>

  <rule pattern="ev">
    <final>r$</final>
  </rule>

  <rule pattern="iv">
    <final>r%</final>
  </rule>

  <rule pattern="ov">
    <final>r&amp;</final>
  </rule>

  <rule pattern="uv">
    <final>r^</final>
  </rule>

  <rule pattern="v">
    <final>r</final>
  </rule>

  <!-- n -->
  <rule pattern="an">
    <final>5E</final>
  </rule>

  <rule pattern="en">
    <final>5R</final>
  </rule>

  <rule pattern="in">
    <final>5T</final>
  </rule>

  <rule pattern="on">
    <final>5U</final>
  </rule>

  <rule pattern="un">
    <final>5Y</final>
  </rule>

  <rule pattern="n">
    <final>5</final>
  </rule>

  <!-- m -->
  <rule pattern="am">
    <final>tE</final>
  </rule>

  <rule pattern="em">
    <final>tR</final>
  </rule>

  <rule pattern="im">
    <final>tT</final>
  </rule>

  <rule pattern="om">
    <final>tU</final>
  </rule>

  <rule pattern="um">
    <final>tY</final>
  </rule>

  <rule pattern="m">
    <final>t</final>
  </rule>

  <!-- r -->
  <rule pattern="a¥">
    <final>6E</final>
  </rule>

  <rule pattern="e¥">
    <final>6R</final>
  </rule>

  <rule pattern="i¥">
    <final>6T</final>
  </rule>

  <rule pattern="o¥">
    <final>6U</final>
  </rule>

  <rule pattern="u¥">
    <final>6Y</final>
  </rule>

  <rule pattern="¥">
    <final>6</final>
  </rule>

  <rule pattern="ar">
    <final>7E</final>
  </rule>

  <rule pattern="er">
    <final>7R</final>
  </rule>

  <rule pattern="ir">
    <final>7T</final>
  </rule>

  <rule pattern="or">
    <final>7U</final>
  </rule>

  <rule pattern="ur">
    <final>7Y</final>
  </rule>

  <rule pattern="r">
    <final>7</final>
  </rule>

  <!-- w -->
  <rule pattern="aw">
    <final>yE</final>
  </rule>

  <rule pattern="ew">
    <final>yR</final>
  </rule>

  <rule pattern="iw">
    <final>yT</final>
  </rule>

  <rule pattern="ow">
    <final>yU</final>
  </rule>

  <rule pattern="uw">
    <final>yY</final>
  </rule>

  <rule pattern="w">
    <final>y</final>
  </rule>

  <!-- y -->
  <rule pattern="ay">
    <final>hD</final>
  </rule>

  <rule pattern="ey">
    <final>hF</final>
  </rule>

  <rule pattern="iy">
    <final>hG</final>
  </rule>

  <rule pattern="oy">
    <final>hJ</final>
  </rule>

  <rule pattern="uy">
    <final>hH</final>
  </rule>

  <rule pattern="y">
    <final>h</final>
  </rule>

  <!-- ' (glottal stop) -->
  <rule pattern="a'">
    <final>nD</final>
  </rule>

  <rule pattern="e'">
    <final>nF</final>
  </rule>

  <rule pattern="i'">
    <final>nG</final>
  </rule>

  <rule pattern="o'">
    <final>nJ</final>
  </rule>

  <rule pattern="u'">
    <final>nH</final>
  </rule>

  <rule pattern="'">
    <final>n</final>
  </rule>
  
  <!-- l -->
  <rule pattern="al">
    <final>j#</final>
  </rule>

  <rule pattern="el">
    <final>j$</final>
  </rule>

  <rule pattern="il">
    <final>j%</final>
  </rule>

  <rule pattern="ol">
    <final>j&amp;</final>
  </rule>

  <rule pattern="ul">
    <final>j^</final>
  </rule>

  <rule pattern="l">
    <final>j</final>
  </rule>
  
  <!-- s -->
  <rule pattern="as">
    <final>iD</final>
  </rule>

  <rule pattern="es">
    <final>iF</final>
  </rule>

  <rule pattern="is">
    <final>iG</final>
  </rule>

  <rule pattern="os">
    <final>iJ</final>
  </rule>

  <rule pattern="us">
    <final>iH</final>
  </rule>

  <rule pattern="s">
    <final>8</final>
  </rule>

  <!-- z -->
  <rule pattern="az">
    <final>,D</final>
  </rule>

  <rule pattern="ez">
    <final>,F</final>
  </rule>

  <rule pattern="iz">
    <final>,G</final>
  </rule>

  <rule pattern="oz">
    <final>,J</final>
  </rule>

  <rule pattern="uz">
    <final>,H</final>
  </rule>

  <rule pattern="z">
    <final>k</final>
  </rule>
  
  <!-- h -->

  <rule pattern="ah">
    <final>9Ñ</final>
  </rule>

  <rule pattern="eh">
    <final>9Š</final>
  </rule>

  <rule pattern="ih">
    <final>9É</final>
  </rule>

  <rule pattern="oh">
    <final>9’</final>
  </rule>

  <rule pattern="uh">
    <final>9å</final>
  </rule>

  <rule pattern="h">
    <final>9</final>
  </rule>
  
  <!-- y -->

  <rule pattern="ay">
    <final>lE</final>
  </rule>

  <rule pattern="ey">
    <final>l</final>
  </rule>

  <rule pattern="iy">
    <final>l</final>
  </rule>

  <rule pattern="oy">
    <final>l</final>
  </rule>

  <rule pattern="uy">
    <final>l</final>
  </rule>

  <rule pattern="y">
    <final>l</final>
  </rule>

  <!-- LONG VOWELS-->

  <rule pattern="[âá]">
    <final>~C</final>
  </rule>

  <rule pattern="[êé]">
    <final>~V</final>
  </rule>

  <rule pattern="[îí]">
    <final>~B</final>
  </rule>

  <rule pattern="[ôó]">
    <final>~M</final>
  </rule>

  <rule pattern="[ûú]">
    <final>~N</final>
  </rule>

  <!-- SHORT VOWELS-->

  <rule pattern="a">
    <final>`C</final>
  </rule>

  <rule pattern="e">
    <final>`V</final>
  </rule>

  <rule pattern="i">
    <final>`B</final>
  </rule>

  <rule pattern="o">
    <final>`M</final>
  </rule>

  <rule pattern="u">
    <final>`N</final>
  </rule>

  <rule pattern="ə">
    <final>¼</final>
  </rule>

  <!-- WHITESPACE / PUNCTUATION -->

  <rule pattern="(\s+)">
    <final>$1</final>
  </rule>

  <rule pattern="!">
    <final>Á</final>
  </rule>

  <rule pattern="\?">
    <final>À</final>
  </rule>

  <rule pattern="\p{Ps}|\p{Pe}">
    <final>›</final>
  </rule>

  <rule pattern="\p{Pd}">
    <final>Â</final>
  </rule>

  <rule pattern=",">
    <final>ˆ</final>
  </rule>

  <rule pattern="\.">
    <final>=</final>
  </rule>

</rules>